package bCommon
{
    import flash.display.DisplayObject;
    
    import mx.core.IFlexDisplayObject;
    import mx.effects.Blur;
    import mx.events.TweenEvent;
    import mx.managers.PopUpManager;
    
    public class PopUpEffect
    {
        
        public function PopUpEffect()
        {
        }

		/**
		 * 特效的显示方法
		 */
        public static function Show(control:IFlexDisplayObject,parent:DisplayObject,modal:Boolean=true,isCenter:Boolean=true):void
        {
            var mShowEffect:Blur=new Blur();
            mShowEffect.blurXFrom=255;
            mShowEffect.blurYFrom=255;
            mShowEffect.blurXTo=0;
            mShowEffect.blurYTo=0;
            mShowEffect.target= control;
            mShowEffect.addEventListener(TweenEvent.TWEEN_START, function():void{
	            PopUpManager.addPopUp(control,parent,modal);
				if(isCenter == true)
	            	PopUpManager.centerPopUp(control);
            });
            mShowEffect.duration = 500;
            mShowEffect.play();
        
        }
		
		/**
		 * 特效的隐藏方法
		 */
        public static function Hide(control:IFlexDisplayObject):void
        {
            
            var mHideEffect:Blur=new Blur();
            mHideEffect.blurXFrom=0;
            mHideEffect.blurYFrom=0;
            mHideEffect.blurXTo=255;
            mHideEffect.blurYTo=255;
            mHideEffect.addEventListener(TweenEvent.TWEEN_END,function():void{
                PopUpManager.removePopUp(control);
            });
            mHideEffect.duration=300;
            mHideEffect.target=control;
            mHideEffect.play();
        }
    }
}
